package hello
import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf,SparkContext}
import org.apache.log4j.{Level, Logger}
object WeiboStatistics {
  def main(args: Array[String]): Unit = {
        val conf = new SparkConf().setMaster("local[2]").setAppName("RDDFlatMap")
        Logger.getLogger("org.apache.spark").setLevel(Level.OFF)
        val sc = new SparkContext(conf)
        transformationOps3(sc)
        sc.stop()
    }
  def transformationOps3(sc: SparkContext): Unit = {
    val text=sc.textFile("C:/Users/asus/Desktop/hadoop_experiment/data/data-1.txt")
    val res1=text.map(line=>line.split(" "))
    val fansNum=0
    val res2=res1.map(x=>(x(0),x(1),x.length-2))
    res2.collect.foreach(println)
    val res3=res2.map(x=>((x._1,x._2),x._3))
    val res4=res3.sortBy(x=>x._2, false).groupBy(x=>x._1._1)
    res4.foreach(println)
  }
}